Declaration of one or more directly →derived data types, name_1 , name_2 must be →IEC-identifiers. Use such declarations to define new type-specific initial values. If you require e.g INT variables with the intial value 5 in →assignments, declare a derived data type (see example myINT below) and then use myINT as data type for the variables used in the assignments.
This declaration is possible within the declaration of a user-defined data type (TYPE ... END_TYPE ). The →base type (data-type ) of the derived data type must be an elementary or user-defined data type (see "Supported data types (in ST)").
Use the optional →initial value := initial-value to assign a value to the derived data type. This value has priority, i.e. the initial value of the base type is "overwritten". If there is no initial value for the derived data type, the initial value of the base type is applied.
:= starts the initialization. The required input for the initialization depends on the base type. For instance, := initial-value assigns a value in case of an elementary base type. But an array data type or a structured data type as base type requires a slightly different input for the initialization. See the description of the corresponding data type for the required syntax for the initialization.
Current restrictions
-
For data-type , it is not possible to enter →reference types (REF_TO ... ), →function blocks or →interfaces.
-
It is possible to nest data types up to 10 levels at the most. Recursions are not possible.
|
The optional attribute SIZE for the bit size is only allowed, if the base type is one of particular elementary data types. The allowed range depends on this data type. Use this attribute to define the bits that will be copied between IO-segment and variable (see the example for data type bit5 in the following).
The attribute SIZE is possible for these elementary data types:
|
The allowed range is:
|
BOOL
|
1 bit
|
SINT , USINT , BYTE
|
1 to 8 bit
|
INT , UINT , WORD
|
1 to 16 bit
|
DINT , UDINT , DWORD
|
1 to 32 bit
|
LINT , ULINT , LWORD
|
1 to 64 bit
|
The attribute SIZE is also allowed for a directly derived data type, if the base type is one of the above listed data types (see the example for data type myBit5_v1 in the following). Direct derivations of a data type with attribute SIZE are allowed without and with attribute SIZE (see the examples for data types myBit5_v2 and myBit3 in the following).
It is possible to use a directly derived data type in all places where it is possible to use the elementary base type. Example: It is possible to use the data type myINT of the following example as input data type for the ADD block, but it is not possible to use the data type typeScalings .
|